package com.polaris.live.adapter

import com.blankj.utilcode.util.StringUtils
import com.blankj.utilcode.util.TimeUtils
import com.polaris.live.R
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.common.cacha.UserManager
import com.polaris.live.common.ext.convertArabicDigitsToNormal
import com.polaris.live.databinding.AdapterInvitePeopleBinding
import com.polaris.live.resp.back_resp.ListResultUserInviteGuestResp
import com.polaris.live.translation.R.string
import com.polaris.live.utils.CommonUtils
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * InviteRewardAdapter
 *
 * @author Created by 半仙 on 2024/4/10/010 15:49
 */
class InvitePeopleAdapter :
    BaseBindingAdapter<AdapterInvitePeopleBinding, ListResultUserInviteGuestResp>() {
    override fun convert(
        holder: VBViewHolder<AdapterInvitePeopleBinding>,
        item: ListResultUserInviteGuestResp,
    ) {
        holder.vb.apply {
            val user = item.userBasic
            avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(user.avatarFrame))
            avatarImg.setImageUrl(user.avatar, user.userId)
            tvInviteRewardName.text = user.nickname
            val millis2String =
                TimeUtils.millis2String(item.createTime, "yyyy-MM-dd HH:mm")
                    .convertArabicDigitsToNormal()
            tvInviteRewardTime.text = StringUtils.getString(string.binding_date, millis2String)
            tvInvitePeopleTotalReward.text =
                StringUtils.getString(string.total_reward, "${item.hisBeans}")
            if (CommonUtils.isMan(UserManager.getUser().sex)) {
                ivRewardsIcon.setImageResource(R.drawable.ic_diamond_small)
            } else {
                ivRewardsIcon.setImageResource(R.drawable.ic_beans)
            }
        }
    }

}